<?
//Data surat yang akan dikirim
				$IdKaryawan1 = $_SESSION['IdKaryawan'];
				$WaktuSekarang1 = date('Y/m/d-H:i:s');
				$JumlahCuti1 = $_POST['JumlahCuti'];
				$KetTgl1 = implode("-", $_POST['KetTgl']);
				$Keperluan1 = $_POST['Keperluan'];
				$Atasan1 = $_POST['Atasan'];
				
				// Mengambil email dari tabel karyawan
				$DKar = mysql_query("SELECT * FROM d_karyawan WHERE id_karyawan = '$IdKaryawan1'");
				$KRY = mysql_fetch_array($DKar);
				
				// Mengambil email dari tabel karyawan
				$Da = mysql_query("SELECT * FROM d_karyawan WHERE tlc = '$Atasan1");
				$ATS = mysql_fetch_array($Da);
				
				//mengirim email
				require_once "Mail.php";
$to = $ATS[email];
$host = "";
$port = "";
$username = "";
$password = "";   

$nama = $_POST['name']; // required
        $pengirim = ""; // required
        $subjek = "Notification Cuti"; // required
        $pesan = "
		$KRY[nama_lengkap] telah mengajukan cuti 
		pada tanggal $KetTgl1
		dengan alasan $Keperluan1
		
		"; // required

$email_message .= "Name: $nama";
        $email_message .= "Email: $pengirim<br>";
        $email_message .= "Subject: $subjek<br>";
        $email_message .= "Comments: $pesan<br>";

$headers = array ('From' => $pengirim,
'To' => $to,
'Subject' => $subjek);       

$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));       

$mail = $smtp->send($to, $headers, $email_message);
if (PEAR::isError($mail))
{
echo("<p>" . $mail->getMessage() . "</p>");}
else {
echo "email success";
}
?>